<template>
	<view class="wrap yjfk-form-right">
		<image class="bgs" src="https://wuyouzhuanapp.oss-cn-beijing.aliyuncs.com/1.png" mode="widthFix"></image>
		<!-- <headers :enable="enable" title="投诉建议" /> -->
	<view  class="form">
		<u-form :model="model" :rules="rules" ref="uForm" label-position="top">
			<u-form-item  :border-bottom="false" label="投诉建议" prop="content">
				<view class="box">
					<u-input type="textarea" placeholder="请填写10字以上的描述以便我们提供更好的帮助"
							v-model="model.content" height="300" maxlength="2000" />
				</view>
			</u-form-item>
			<u-form-item  :border-bottom="false" label="相关截图（选填）0/4" >
				<u-upload   multiple maxCount="4" ref="uUpload" :show-progress="false" 
					action="https://hegui.kaisenbaoxian.com/personnelManage/file/uploadImg" :auto-upload="true"
				 :file-list="fileList1"
					>
				</u-upload>
			</u-form-item>
			
			
			<u-form-item  :border-bottom="false" label="联系方式" prop="contact">
				<view class="box box1">
				<u-input  class="input-left-form" placeholder="请输入您的联系方式"
						v-modtel="model.contact" type="text" maxlength="200"></u-input>
						</view>
			</u-form-item>
		</u-form>
		<view class="u-m-t-80">
			<u-button shape="circle" type="primary" @click="submit">提交投诉</u-button>
		</view>
	</view>
	</view>
</template>
<script>
import headers from '@/components/headnavbar/index.vue'
export default {
	onPageScroll(e) {
		this.enable = e.scrollTop > 100 ? true : false
	},
	components: {
		headers
	},
	data() {
		
		return {
			enable: false,
			fileList1:[],
			model: {
				
				content: '',
				contact: '',
			},
			rules: {
				contact: [
					{
						required: true,
						message: '请输入您的联系方式',
						trigger: ['change','blur'],
					}
				],
				content: [
					{
						required: true,
						min: 10, max: 500,
						message: '问题和意见在 10 到 2000 个字符之间',
						trigger: ['change','blur'],
					}
				],
			}
		};
	},
	onReady() {
		this.$refs.uForm.setRules(this.rules);
		// 获取设备信息
		uni.getSystemInfo({
			success: res => {
				this.model.deviceInfo = JSON.stringify(res);
			}
		});
	},
	methods: {
		submit() {
			// console.log(this.model)
			this.$refs.uForm.validate(valid => {
				if (valid) {
					this.$u.api.commentSave(this.model).then(res => {
						uni.showModal({
							title: '提示',
							content: res.message,
							showCancel: false,
							success: function () {
								if (res.result == 'true') {
									uni.navigateBack();
								}
							}
						});
					});
				} else {
					this.$u.toast('您填写的信息有误，请根据提示修正。');
				}
			});
		},
		cancel() {
			uni.navigateBack();
		}
	}
};
</script>
<style lang="scss" scoped>
.input-placeholder{
	text-align: right;
}
.form{
		// min-height: 130vh;
}
.box{
	background: #fff;
	width: 100%;
	padding: 22rpx 31rpx;
	border-radius: 13rpx;
}
.box1{
	padding:10rpx 31rpx;
}
/deep/ .u-input,/deep/ .u-list-item{
	background: #fff !important;
	
}

</style>
